-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r/aws_globalaccelerator_accelerator: Add aws_globalaccelerator_accelerator resource #7002
r/aws_globalaccelerator_accelerator: Add aws_globalaccelerator_accelerator resource #7002
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @gazoakley 👋 Thanks for submitting this! Initial feedback below. Please reach out with any questions or if you do not have time to address the items.
"ip_address_type": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this instead include the default for drift detection?
Computed: true, | |
Default: globalaccelerator.IpAddressTypeIpv4, |
"enabled": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Computed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this instead include the default for drift detection?
Computed: true, | |
Default: true, |
"attributes": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
Computed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DiffSuppressFunc
below should allow Computed: true
to be removed here.
"flow_logs_enabled": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Computed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this instead default to false
for drift detection?
Computed: true, | |
Default: false, |
"flow_logs_s3_bucket": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we shouldn't be ignoring this value for drift detection and should remove Computed: true
.
`, rInt) | ||
} | ||
|
||
func testAccGlobalAcceleratorAccelerator_update(rInt int) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test configuration function goes away when using name instead of integer. 👍
testAccCheckGlobalAcceleratorAcceleratorExists(resourceName), | ||
resource.TestCheckResourceAttr(resourceName, "attributes.#", "1"), | ||
resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_enabled", "true"), | ||
resource.TestMatchResourceAttr(resourceName, "attributes.0.flow_logs_s3_bucket", regexp.MustCompile("tf-.*")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use resource.TestCheckResourceAttrPair()
instead of regex to ensure its value is correct.
s3BucketResourceName := "aws_s3_bucket.example"
// ...
resource.TestCheckResourceAttrPair(resourceName, "attributes.0.flow_logs_s3_bucket", s3BucketResourceName, "bucket"),
resource.TestMatchResourceAttr(resourceName, "name", regexp.MustCompile("tf-.*")), | ||
resource.TestCheckResourceAttr(resourceName, "enabled", "false"), | ||
resource.TestCheckResourceAttr(resourceName, "ip_address_type", "IPV4"), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This check should also include attributes
and ip_sets
in some form.
globalaccelerator.IpAddressTypeIpv4, | ||
}, false), | ||
}, | ||
"enabled": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should include an acceptance test that creates/updates enabled = true
State: schema.ImportStatePassthrough, | ||
}, | ||
|
||
Timeouts: &schema.ResourceTimeout{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for these custom timeouts is not present on the resource documentation page, but is there a reason why they are customizable to begin with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was good practise to offer customisable timeouts if code needs to do a wait, but I can't imagine users would want to change the defaults very often. Would it be better to add documentation or remove the ability to customize timeouts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally want to err on the side of not providing it unless its dependent on some scalable resource (e.g. amount of data in a database) or fluctuates based on AWS-background processes (e.g. varying ENI removal time from load balancers when trying remove subnets). We can always add it later if necessary.
Happy New Year @bflad 🎉 - I'll make the updates shortly. One thing I meant to ask about was what would be the best way to deal with deletion when an accelerator is enabled - the call to
Any preference? |
Interesting and happy new year as well! Got to love how none of these services are consistent. 😂 First or third option sounds good, whatever is easiest. |
Config: testAccGlobalAcceleratorAccelerator_basic(rName, true), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckGlobalAcceleratorAcceleratorExists(resourceName), | ||
resource.TestCheckResourceAttr(resourceName, "name", newName), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be rName
😄
--- FAIL: TestAccAwsGlobalAcceleratorAccelerator_update (35.05s)
testing.go:538: Step 0 error: Check failed: Check 2/3 error: aws_globalaccelerator_accelerator.example: Attribute 'name' expected "tf-acc-test-1060790186692934857", got "tf-acc-test-4121192575072923489"
resource.TestCheckResourceAttr(resourceName, "name", newName), | |
resource.TestCheckResourceAttr(resourceName, "name", rName), |
Changes: * Remove `Computed: true` from `attributes` attribute * Fix `TestAccAwsGlobalAcceleratorAccelerator_update` check Output from acceptance testing: ``` --- PASS: TestAccAwsGlobalAcceleratorAccelerator_basic (55.12s) --- PASS: TestAccAwsGlobalAcceleratorAccelerator_attributes (69.74s) --- PASS: TestAccAwsGlobalAcceleratorAccelerator_update (89.72s) ```
Whoops didn't post my approval first 😅 Thanks, @gazoakley! 🚀
|
This has been released in version 1.56.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Partly addresses #6739
Changes proposed in this pull request:
aws_globalaccelerator_accelerator
Output from acceptance testing: